<script setup>
import { ref } from 'vue'
import { useUserStore } from '@/stores/index'
const userStore = useUserStore()

const form = ref({
  loginName: '',
  passWrd: ''
})
import { login } from '@/api/login'
import { useRouter } from 'vue-router'
const router = useRouter()
const onSubmit = async () => {
  const result = await login(form.value)
  userStore.setToken(result.data.data.token)
  console.log(form, result)
  router.push('/')
}
</script>
<template>
  {{ userStore }}
  <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="用户名">
      <el-input v-model="form.loginName" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.passWrd" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
      <el-button>重置</el-button>
    </el-form-item>
  </el-form>
</template>
<style scoped="true"></style>
